/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    usart.h
  * @brief   This file contains all the function prototypes for
  *          the usart.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

#define U2_RX_SIZE  (4*32)
#define U2_TX_SIZE  (4*32)
#define U3_RX_SIZE  (4*32)
#define U3_TX_SIZE  (4*32)
#define U7_RX_SIZE  (4*32)
#define U7_TX_SIZE  (4*32)

extern __ALIGNED(32) uint8_t g_U2RxBuffer[U2_RX_SIZE];
extern __ALIGNED(32) uint8_t g_U2TxBuffer[U2_TX_SIZE];
extern uint8_t g_U2RxCplt; /* δ��DMAʹ�� */
extern uint8_t g_U2RxSize; /* δ��DMAʹ�� */

extern __ALIGNED(32) uint8_t g_U3RxBuffer[U3_RX_SIZE];
extern __ALIGNED(32) uint8_t g_U3TxBuffer[U3_TX_SIZE];
extern uint8_t g_U3RxCplt; /* δ��DMAʹ�� */
extern uint8_t g_U3RxSize; /* δ��DMAʹ�� */

extern __ALIGNED(32) uint8_t g_U7RxBuffer[U7_RX_SIZE];
extern __ALIGNED(32) uint8_t g_U7TxBuffer[U7_TX_SIZE];
extern __IO uint8_t g_U7RxCplt; /* δ��DMAʹ�� */
extern __IO uint8_t g_U7RxSize; /* δ��DMAʹ�� */

// RS485�շ�ʹ�ܿ���
#define RS485_DE  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_SET)
#define RS485_RE   HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET)

#define UART_BUFFER_SIZE        (128)   /* �������ݻ�������С */
#define UART_QUEUE_QUANTITY     (32)    /* ���ڶ��е���Ϣ���� */

typedef struct
{
    __ALIGNED(32) uint8_t buffer[UART_BUFFER_SIZE];   /* ������ݵĿռ� */
    uint16_t size;                      /* �Ѵ�����ݵĴ�С */
} UART_DATA_T;                          /* �洢�봮����ص����ݽṹ�� */

#define BSP_UART_10              USART10      /* ����ַ */
#define BSP_UART10               huart10      /* ��� */
#define BSP_UART10_DMA_RX        hdma_usart10_rx
#define BSP_UART10_DMA_TX        hdma_usart10_tx

/* USER CODE END Includes */

extern UART_HandleTypeDef huart5;

extern UART_HandleTypeDef huart7;

extern UART_HandleTypeDef huart2;

extern UART_HandleTypeDef huart3;

extern UART_HandleTypeDef huart10;

/* USER CODE BEGIN Private defines */


/* USER CODE END Private defines */

void MX_UART5_Init(void);
void MX_UART7_Init(void);
void MX_USART2_UART_Init(void);
void MX_USART3_UART_Init(void);
void MX_USART10_UART_Init(void);

/* USER CODE BEGIN Prototypes */
void AppUART3_Init(void);
void AppUART7_Init(void);
void AppUART2_Init(void);
void bsp_uart10_init(void);                           /* ����10��ʼ�� */
void hal_uart10_idle_callback(void);                  /* ����10�����жϻص����� */
uint8_t bsp_uart10_send(uint8_t *data, uint16_t len); /* ����10�������� */
/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __USART_H__ */

